/* 一、 将下面异步代码使用Promise的方式改进
setTimeout(function () {
  var a = 'hello'
  setTimeout(function () {
    var b = 'lagou'
    setTimeout(function () {
      var c = 'I ❤ you'
      console.log(a + b + c)
    }, 10)
  },10)
},10) */

function timerPromise(str, delay = 10) {
  return new Promise(resolve => setTimeout(() => resolve(str), delay))
}

// then
timerPromise('hello')
  .then(res => timerPromise(`${res}lagou`))
  .then(res => timerPromise(`${res}I ❤ you`))
  .then(console.log)


// async await
async function asyncConcat() {
  let a = await timerPromise('hello')
  let b = await timerPromise('lagou')
  let c = await timerPromise('I ❤ you')
  console.log(a + b + c)
}
asyncConcat()